package com.ym.script.command;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import dalvik.system.PathClassLoader;

public class Pm {
	// com.android.commands.am.Am
	static PathClassLoader loader = new PathClassLoader(
			"/system/framework/pm.jar", ClassLoader.getSystemClassLoader());
	static Class<?> clzz;
	static Method runFuction;
	static Object instance;
	static {
		try {
			clzz = loader.loadClass("com.android.commands.pm.Pm");
			instance = clzz.newInstance();
			runFuction = clzz.getMethod("run", new String[0].getClass());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void run(String args) {
		run(args.split(" "));
	}

	public static void run(String[] args) {
		try {
			runFuction.invoke(instance, new Object[] { args });
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
